<template>
  <div>
    <link rel="stylesheet" href="https://g.alicdn.com/de/prismplayer/2.9.3/skins/default/aliplayer-min.css" />
    <script type="text/javascript" charset="utf-8" src="https://g.alicdn.com/de/prismplayer/2.9.3/aliplayer-min.js"></script>
    <div id="player-con"></div>
  </div>
</template>
<script>
import courseApi from '@/api/course'

export default {
    layout: 'video',//应用video布局
    asyncData({ params, error }) {
       return courseApi.getCourseFrontInfo(params.video)
        .then(response => {
          let course = response.data.data.eduCourse
          let chapterVos = response.data.data.chapterVos
          let courseId = params.video
          let isbuy = response.data.data.isBuy
          return {
              course,
              chapterVos,
              courseId,
              isbuy
          }
        })
    },
    mounted() { //页面渲染之后  created

      let address = 'https://outin-8efceefb267211eb8a4a00163e1c35d5.oss-cn-shanghai.aliyuncs.com/sv/1ae967c5-177e8815437/1ae967c5-177e8815437.mp4?Expires=1614650764&OSSAccessKeyId=LTAIrkwb21KyGjJl&Signature=wSAQsPZOaAu2vJVNM7V5nPwtxE0%3D'
      var player = new Aliplayer({
        id: "player-con",
        source: address,
        width: "100%",
        height: "500px",
        cover: 'http://guli.shop/photo/banner/1525939573202.jpg',
        /* To set an album art, you must set 'autoplay' and 'preload' to 'false' */
        autoplay: false,
        preload: false,
        isLive: false
      }, function (player) {
        console.log("The player is created");
      });
    }
}
</script>
